package threading;

/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2022-08-19
 * Time:22:02
 */

/**
 * 实现Runnable接口,重写run
 */

class MyRunnable implements Runnable{
    @Override
    public void run() {
        while (true) {
            System.out.println("hello threading");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
public class Demo2 {
    public static void main(String[] args) {
        MyRunnable myRunnable = new MyRunnable();
        Thread threading = new Thread(myRunnable);
        threading.start();
        while (true){
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }


}

